import lejos.nxt.Battery;
import lejos.nxt.Button;
import lejos.nxt.ButtonListener;
import lejos.nxt.MotorPort;


public class TestDrehgeber {
	private static int power = 100;
	private static int stop = 100;
	
	public TestDrehgeber() {
		MotorPort.A.resetTachoCount();
		
		System.out.println("U = " + Battery.getVoltage() + "V");
		System.out.println("> druecken!");
		Button.waitForAnyPress();
		
		Button.LEFT.addButtonListener(new ButtonListener() {
			public void buttonReleased(Button arg0) {
				MotorPort.A.controlMotor(stop, MotorPort.STOP);
				System.out.println(MotorPort.A.getTachoCount());
			}
			
			public void buttonPressed(Button arg0) {
				MotorPort.A.controlMotor(power, MotorPort.BACKWARD);
				System.out.println(MotorPort.A.getTachoCount());
			}
		});
		
		Button.RIGHT.addButtonListener(new ButtonListener() {
			public void buttonReleased(Button arg0) {
				MotorPort.A.controlMotor(stop, MotorPort.STOP);
				System.out.println(MotorPort.A.getTachoCount());
			}
			
			public void buttonPressed(Button arg0) {
				MotorPort.A.controlMotor(power, MotorPort.FORWARD);
				System.out.println(MotorPort.A.getTachoCount());
			}
		});
		
		while(Button.ESCAPE.isUp()) {
			
		}
	}
	
	public static void main(String[] args) {
		new TestDrehgeber();
	}
}
